package com.iori.springsecurityjwt.security;

import com.iori.springsecurityjwt.bean.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

@Service
public class JWTUserDetailService implements UserDetailsService{
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        if(username.equals("admin")){
            User user = new User();
            user.setUsername(username);
            return new JWTUserDetails(user);
        }else{
            throw new UsernameNotFoundException("can not find user.");
        }
    }
}
